//时间
charset="utf-8"
function fn(){
    var time = new Date();
    var str= "";
    var div = document.getElementById("time");
    var greeting =document.getElementById("greeting")
//    console.log(time);
    var year = time.getFullYear();
    var mon = time.getMonth()+1;
    var day = time.getDate();
    var h = time.getHours();
    var m = time.getMinutes();
    var s = time.getSeconds();
    var week = time.getDay();
    switch (week){
        case 0:week='\u661F\u671F\u65E5'; //星期日
            break;
        case 1:week='\u661F\u671F\u4E00'; //星期一
            break;
        case 2:week='\u661F\u671F\u4E8C'; // "星期二"
            break;
        case 3:week='\u661F\u671F\u4E09'; // "星期三"
            break;
        case 4:week='\u661F\u671F\u56DB'; // "星期四"
            break;
        case 5:week='\u661F\u671F\u4E94'; // "星期五"
            break;
        case 6:week='\u661F\u671F\u516D'; // "星期六"
            break;
    }            // "年"             "月"                 '日'
    str = year +'\u5E74'+totwo(mon)+'\u6708'+totwo(day)+'\u65E5'+"&nbsp;"+totwo(h)+":"+totwo(m)+":"+totwo(s)+"&nbsp;"+week;
    div.innerHTML = str;
    if (totwo(h)>=0 && totwo(h) < 4){
        greeting.innerHTML = '\u5348\u591C\u597D'; // "午夜好"
    }else if (totwo(h) >= 4 && totwo(h) < 6){
        greeting.innerHTML = '\u6E05\u6668\u597D'; // "清晨好"
    }else if(totwo(h) >= 6 && totwo(h) < 9){
        greeting.innerHTML = '\u65E9\u4E0A\u597D'; // "早上好"
    }else if (totwo(h) >= 9 && totwo(h) < 12 ){
        greeting.innerHTML = '\u4E0A\u5348\u597D'; // "上午好"
    }else if (totwo(h) >= 12 && totwo(h)< 13){
        greeting.innerHTML = '\u4E2D\u5348\u597D'; // "中午好"
    }else if (totwo(h) >= 13 && totwo(h) < 18){
        greeting.innerHTML = '\u4E0B\u5348\u597D'; // "下午好"
    }else if (totwo(h) >= 18 && totwo(h) < 20){
        greeting.innerHTML = '\u508D\u665A\u597D'; // "傍晚好"
    }else
        greeting.innerHTML = '\u665A\u4E0A\u597D'; //  晚上好

}
fn();
setInterval(fn,1000);
function totwo(n){
    if(n<=9){
        return n = "0"+n;
    }
    else{
        return n =""+n;
    }
}

